package com.sthz.facepay.mapper;

import com.sthz.facepay.model.BigClassification;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.apache.ibatis.type.JdbcType;

public interface BigClassificationMapper {
    @Delete({
        "delete from st_big_classification",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into st_big_classification (id, name, ",
        "sbid)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{sbid,jdbcType=INTEGER})"
    })
    int insert(BigClassification record);

    @InsertProvider(type=BigClassificationSqlProvider.class, method="insertSelective")
    int insertSelective(BigClassification record);

    @Select({
        "select",
        "id, name, sbid",
        "from st_big_classification",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="sbid", property="sbid", jdbcType=JdbcType.INTEGER),
        @Result(column="sbid", property="subclassification", one=@One(select="com.sthz.facepay.mapper.SubclassificationMapper.getById",fetchType = FetchType.EAGER))
    })
    BigClassification selectByPrimaryKey(Integer id);

    @UpdateProvider(type=BigClassificationSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(BigClassification record);

    @Update({
        "update st_big_classification",
        "set name = #{name,jdbcType=VARCHAR},",
          "sbid = #{sbid,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(BigClassification record);
}